import axios from '../../utils/http'

const model = {
    namespaced: true, //形成对立的命名空间
    state(){
        //数据
        return {
            specsList: [],
            count: 0
        }    
    },
    mutations: {
        specsCountMutation(state,count){
            //设置数据
            state.count = count
        },
        specsListMutation(state,list){
            //设置数据
            state.specsList = list
        }
    },
    actions: {
        specsCountActions(context){
            //请求数据
            axios.get("/specscount").then(res=>{
                context.commit("specsCountMutation",res.list[0].total)
            })
        },
        specsListActions(context,obj){
            //请求数据
            //obj = {page: 1,size: 2}
            axios.get("/specslist",{params:obj}).then(res=>{
                context.commit("specsListMutation",res.list)
            })
        }
    }
}

export default model